/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.admin.dto.PlanContentSaveDto;
import org.springblade.modules.admin.dto.sugar.SugarSearchDTO;
import org.springblade.modules.admin.entity.Building;
import org.springblade.modules.admin.dto.sugar.mal.SugarMalSearchDTO;
import org.springblade.modules.admin.entity.MaintainMalfunctionWork;
import org.springblade.modules.admin.entity.MaintainPlanContent;
import org.springblade.modules.admin.entity.MaintainPlanContentExt;
import org.springblade.modules.admin.vo.MaintainMalfunctionWorkVO;
import org.springblade.modules.admin.vo.MalFunctionDetailVO;
import org.springblade.modules.admin.vo.elevator.ProblemItemVo;
import org.springblade.modules.admin.vo.parts.MaintainMalfunctionWorkDetailVo;
import org.springblade.modules.admin.vo.parts.MalfunctionPartsTreeVO;
import org.springblade.modules.admin.vo.plan.MalfunctionWorkSummaryVo;
import org.springblade.modules.admin.vo.plan.wx.BiWxPlanDetailVo;
import org.springblade.modules.admin.vo.plan.wx.WxUserPlanVo;
import org.springblade.modules.admin.vo.plan.wx.bi.BiWxUserPlanVo;
import org.springblade.modules.admin.vo.sugar.StatisticsTrendVO;
import org.springblade.modules.admin.vo.sugar.map.BuildingMapVo;
import org.springblade.modules.admin.vo.sugar.mal.ElevatorMalTopVO;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 故障工单明细 服务类
 *
 * @author BladeX
 * @since 2021-05-11
 */
public interface IMaintainMalfunctionWorkService extends BaseService<MaintainMalfunctionWork> {


	String WX_USER_PLAN_KEY="wx_user_plan:";


	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param maintainMalfunctionWork
	 * @return
	 */
	IPage<MaintainMalfunctionWorkVO> selectMaintainMalfunctionWorkPage(IPage<MaintainMalfunctionWorkVO> page, MaintainMalfunctionWorkVO maintainMalfunctionWork);

	MalFunctionDetailVO getMalfunctionWorkDetail(Long planId);

	List<MalFunctionDetailVO> getMalfunctionWorkDetailList(List<Long> planIds);

	/**
	 * 根据工单id 获取项目信息
	 * @param planId
	 * @return
	 */
	MaintainMalfunctionWorkDetailVo getDetail(Long planId);

	/**
	 * 获取维修汇总明细
	 * @return 数据集
	 */
	MalfunctionWorkSummaryVo getSummaryDetail();

	/**
	 * 获取电梯的故障类型统计
	 * @param elevatorId 电梯id
	 */
	List<ProblemItemVo> getElevatorFaultList(Long elevatorId);


	/**
	 * 根据电梯获取维修列表
	 * @param elevatorId
	 * @return
	 */
    MalfunctionWorkSummaryVo getMalfunctionWorkElevatorInfo(Long elevatorId);

	/**
	 * 维修新增人员
	 * @param planId 工单id
	 * @param userIds 用户ids
	 * @return 数据集
	 */
	Boolean addMalfunctionWorkUser(Long planId, String userIds);

	List<MalfunctionPartsTreeVO> selectMalPartsTree(String keyWord);

    List<ElevatorMalTopVO> selectElevatorMalTopTen(SugarMalSearchDTO searchDTO);


	/**
	 * 根据工单获取所有的维修中的项目信息
	 * @return 数据集
	 */
	List<Building> getBuildingListOfPlan(SugarSearchDTO searchDTO);

	/**
	 * 地图信息的项目维修信息
	 * @param buildingId 项目id
	 * @return 数据集
	 */
	BuildingMapVo getBuildingMapInfo(SugarSearchDTO searchDTO);

    List<StatisticsTrendVO> selectMalProblemItem(SugarMalSearchDTO searchDTO);

    List<StatisticsTrendVO> selectMalPlanTime(SugarMalSearchDTO searchDTO);

    List<ElevatorMalTopVO> selectMalPlanTop(SugarMalSearchDTO searchDTO);

    Object initMal();

	Object initFix();


	/**
	 * 维修转派人员
	 * @param planId 工单id
	 * @param userIds 用户ids
	 * @return 数据集
	 */
	Boolean giveOtherUser(Long planId, String userIds);

    List<MaintainMalfunctionWork> listByPlanId(Long planId);


	/**
	 * 发送预警通知
	 * @param planContentSaveDto 参数
	 * @param planId 工单id
	 */
	void sendYjMsg(PlanContentSaveDto planContentSaveDto, Long planId);


	/**
	 * 用户今日的工单列表
	 * @return 数据集
	 */
	List<WxUserPlanVo> userPlanListOfToday();

	/**
	 * 获取bi维修工单明细
	 * @param beginTime 开始时间
	 * @param endTime 结束时间
	 * @return 数据集
	 */
    List<BiWxPlanDetailVo> getBiWxPlanDetailList(Date beginTime, Date endTime);


	/**
	 * 获取bi人员工单明细
	 * @param beginTime 开始时间
	 * @param endTime 结束时间
	 * @return 数据集
	 */
	List<BiWxUserPlanVo> getBiWxUserPlanDetail(Date beginTime, Date endTime);


    List<Map<String, Object>> getBiWxPlanDetailListV2();

	List<Map<String, Object>> galaxyRepairPlanCountJobV2();
}
